<%--
  Created by IntelliJ IDEA.
  User: mafh
  Date: 2017/6/16 0016
  Time: 14:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%!
    /**
     * 修改密码
     * @param input
     * @return
     */
    public Message changePassword(Input input){
        Message msg = new Message();
        Integer hospital = input.getInt("hospital",-999);
        String userName = input.getDesc("user_name","");
        String oldPassword = input.getDesc("old_password","");
        String newPassword = input.getDesc("new_password","");
        List<ManageUser> userList = QBuilder.db("basedb").select().from("ManageUser").where(new Where("hospital=",hospital).and("userName=",userName).and("password=",oldPassword).and("status=",STATUS_ENABLE)).query().getResultObj();
        if(userList.size()==1){//验证成功
            ManageUser user = userList.get(0);
            user.setPassword(newPassword);
            user.setOperatorName(user.getName());
            user.setOperatorUid(user.getId());
            try {
                DBTools.db("basedb").modItem(user,user.getId());
            }catch (Exception e){
                e.printStackTrace();
                msg.setErrcodeAndErrmsg(23333,"修改密码失败");
            }
        }else{
            msg.setErrcodeAndErrmsg(23333,"原密码错误");
        }
        return msg;
    }
%>
